package com.jack.thinking.thread.core._1;

/**
 * thread's priority can be extends.
 * thread's priority decide on parent thread when create the thread.
 * here 
 * MyThreadPriority's create in Main's thread(priority=5), 
 * MyThreadPriority1's create in MyThreadPriority's thread(priority=8)
 * @author wangbingwu
 *
 */
public class PriorityExtends {
	public static void main(String[] args) {
		Thread t = new Thread(new MyThreadPriority());
		t.setPriority(8);
		t.start();
		System.out.println("Thread priority: " + Thread.currentThread().getPriority());
	}
}/** Output
Thread priority: 5
MyThreadPriority priority: 5
MyThreadPriority1 priority: 8
*/

class MyThreadPriority extends Thread{
	@Override
	public void run() {
		System.out.println("MyThreadPriority priority: " + this.getPriority());
		MyThreadPriority1 p1 = new MyThreadPriority1();
		p1.start();
	}
}

class MyThreadPriority1 extends Thread{
	@Override
	public void run() {
		System.out.println("MyThreadPriority1 priority: " + this.getPriority());
	}
}